package com.atguigu.rabbit.consumer.listener;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @BelongsProject: rabbitmq-parent-0528
 * @BelongsPackage: com.atguigu.rabbit.consumer.listener
 * @Author: jiangyi
 * @CreateTime: 2025-09-15  22:52
 * @Description: TODO
 * @Version: 1.0
 */
@Component
public class DelayedListener01 {

    @RabbitListener(queues = "queue.delay.order")
    public void delayedQueueDemo(Channel channel, Message message, String msg) throws IOException {

        byte[] body = message.getBody();
        String msgStr = new String(body);
        System.out.println("=================="+msg+"==================");
        System.out.println("=============延迟消息测试=============");


        long deliveryTag = message.getMessageProperties().getDeliveryTag();
        channel.basicAck(deliveryTag,false);
    }
}
